<?php
include "./library.php";
$arr = pg_fetch_all(pg_query("select max(tid) as latest from carpool.tripinfo"));
$arr1 = pg_fetch_all(pg_query("select tid, depart_time from carpool.tripinfo"));
$tid = $arr[0][latest]+1;
$time = $_POST[tour_Year] . "-" .  $_POST[tour_Month] . "-" . $_POST[tour_Day]  . $_POST[tour_Time] . ":" . "00";
pg_query("insert into carpool.tripinfo values('".$tid."' , '".$_POST[to]."', '".$_POST[from]."' , '".$time."','".'False'."')");
pg_query("insert into carpool.tripmembers values('".$tid."' , '".$_SESSION[user]."')");
echo "<script>alert('Registration completed.')</script>";
echo '<script>window.location="./search.php"</script>';
?>